﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RCP
{
    public partial class frmRDPPrint : Form
    {
        public frmRDPPrint()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //public static extern int PrintStr(byte[] printer, byte[] strText, int x, int y, int direction, byte[] fontname, int fontsize);
            string m_str = this.content_tb.Text;

            if (m_str == "") return;
            byte[] printer = System.Text.Encoding.Default.GetBytes("RDPrinter1.1");
            byte[] strText = System.Text.Encoding.Default.GetBytes(m_str);
            byte[] fontname = System.Text.Encoding.Default.GetBytes(this.font_tb.Text);
            int x = int.Parse(this.x_tb.Text);
            int y = int.Parse(this.y_tb.Text);
            int direction = 0;
            if (this.radioButton1.Checked)
            {
                direction = int.Parse(radioButton1.Tag.ToString());
            }
            if (this.radioButton2.Checked)
            {
                direction = int.Parse(radioButton2.Tag.ToString());
            }
            int fontsize = int.Parse(this.fontsize_tb.Text);
            int ret = RCPClass.RCP11Class.PrintStr(printer, strText, x, y, direction, fontname, fontsize);
            if (ret == 0)
            {
                MessageBox.Show("打印成功");
            }
            else
            {
                MessageBox.Show("打印失败");
            }
        }
    }
}
